package de.koller.enc.render;

import de.koller.enc.ENode;
import de.koller.oceanFramework.tree.Child;
import org.lwjgl.opengl.GL11;

public class EncRender extends ENode {

	public static final int S_WIDTH = 800, S_HEIGHT = 600;
	
	private Grid grid;
	@Child public final Camera camera = new Camera();
	
	@Override
	protected void init() {
		super.init();
		GL11.glMatrixMode( GL11.GL_PROJECTION );
		GL11.glLoadIdentity();

		GL11.glOrtho( 0, S_WIDTH, S_HEIGHT, 0, -1000, 1000 );
		
		GL11.glMatrixMode( GL11.GL_MODELVIEW );
		GL11.glLoadIdentity();
		
		GL11.glEnable( GL11.GL_CULL_FACE );
		GL11.glCullFace( GL11.GL_BACK );

		GL11.glEnable( GL11.GL_DEPTH_TEST );
		GL11.glDepthFunc( GL11.GL_LEQUAL );
		
		GL11.glAlphaFunc( GL11.GL_GREATER, 0.1f );
		GL11.glEnable( GL11.GL_ALPHA_TEST );
		
		grid = new Grid();
	}
	
	public final void renderSzene() {
		GL11.glClear( GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT );
		GL11.glColor3f( 1, 1, 1 );
		
		grid.draw( camera );
		camera.preTransform();
		
		camera.postTransform();
	}
	
}
